#include "AccusationView.h"

#include <boost/bind.hpp>
#include "../../../utils/LateEvents.hpp"
#include "../../helpers/console/CardsHelper.h"

using namespace Views::Graphic;
using namespace Views::Helpers::Graphic::Accusation;
using namespace Utils;

AccusationView::AccusationView(GUI::Form* form):
BaseGraphicView(form), decision_dialog(NULL), accusation_cards_dialog(NULL)
{
}

void AccusationView::askIfPlayerWantsToPerformAccusation()
{
	decision_dialog = new DecisionDialog();
	decision_dialog->Move(50, 50);
	decision_dialog->doOnDecisionSet(LateAppLoopEventFactory::create(&AccusationView::onDecisionSet, this));

	Form->addChild(decision_dialog);
	decision_dialog->Move(200, 200);
	Form->Draw(true);
}

void AccusationView::onDecisionSet(bool decision)
{
	delete decision_dialog;
	decision_dialog = NULL;
	playerDecisionSetEvent(decision);
}

void AccusationView::askForCardsInAccusation(Cards::CardsCollection cards)
{
	accusation_cards_dialog = new AccusationCardsDialog(cards);
	accusation_cards_dialog->Move(50, 20);
	accusation_cards_dialog->doOnCardsSet(LateAppLoopEventFactory::create(&AccusationView::onCardsSet, this));

	Form->addChild(accusation_cards_dialog);
	Form->Draw(true);
}

void AccusationView::onCardsSet(Cards::CardSet cards)
{
	delete accusation_cards_dialog;
	accusation_cards_dialog = NULL;
	cardsInAccusationSetEvent(cards);
}
